<?php 
if($error){
?><div align="center">
<div class="ui-widget ui-widget-content ui-corner-all" style="width: 30%;padding: 2px;">
	<h3>
	<?php echo __("Invalid hash. If you requested more than one password recovery email please note that only the last is valid");?>
	</h3>
</div></div>
<?php }else{
?><input type="hidden" id="hash" value="<?php echo $hash;?>">
<div align="center">
<div class="ui-widget ui-widget-content ui-corner-all" style="width: 30%;padding: 2px;">
	<h3>Recupera tu contrase&ntilde;a</h3>
	<div class="sub">
		<table>
			<tr><td>Nombre</td><td><?php echo $firstname;?></td></tr>
			<tr><td>Apellido</td><td><?php echo $lastname;?></td></tr>
			<tr><td>Correo electr&oacute;nico</td><td><?php echo $email;?></td></tr>
			<tr><td>Nombre de usuario</td><td><?php echo $username;?></td></tr>
			<tr><td>Contrase&ntilde;a</td><td><input id="pass1" type="password" class="check text ui-widget-content ui-corner-all"></td></tr>
			<tr><td>Confirma contrase&ntilde;a</td><td><input id="pass2" type="password" class="check text ui-widget-content ui-corner-all"></td></tr>
		</table>
		<br/>
		<button>Cambiar contrase&ntilde;a</button>
	</div>
	<br>
</div>
</div>
<script>
$(document).ready(function(){

$("button").button().click(function(){
	$(".check").removeClass("ui-state-error");
	var pass1 = $.trim($("#pass1").val()),
		pass2 = $.trim($("#pass2").val());

	if(pass1.length == 0 || pass1!=pass2){
		jAlert("Los campos de contrase&ntilde;a no coinciden","Error");
		$("#pass1").addClass("ui-state-error").focus();
		$("#pass2").addClass("ui-state-error");
	}else{
	
			$.post("/core/account/newPassword",{password:pass1,hash:$("#hash").val()},function(data){
				data = eval("("+data+")");
				if(data.error){
					jAlert(data.message,"Error");
				}
				else{
					jAlert("Ya puedes usar tu nueva contrase&ntilde;a","Aviso",function(){
						location.href="/";
					});
				}
			});
	}
	});

});
</script>
<?php }?>